package com.blog1.controller;

import com.blog1.pojo.request.LoginRequest;
import com.blog1.pojo.response.LoginResult;
import com.blog1.pojo.response.UserInfoResponse;
import com.blog1.service.UserInfoService;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/user")
public class UserController {
    @Resource(name = "userInfoServiceImpl")
    private UserInfoService userInfoService;
    @RequestMapping("/login")

    public LoginResult login(@RequestBody @Validated LoginRequest request){
        log.info("登录");
return userInfoService.login(request);
    }

    @RequestMapping("/getUserInfo")
    public UserInfoResponse getUserInfo(@NotNull int userId){

        return userInfoService.getUserInfo(userId);
    }

    @RequestMapping("/getAuthorInfo")
    public UserInfoResponse getAuthorInfo(@NotNull int blogId){
return userInfoService.getAuthorInfo(blogId);
    }



}
